package com.lanou.quanttradedata.stock.controller;

import com.lanou.quanttradedata.stock.service.StockService;
import com.lanou.quanttradedata.utils.javabean.RestObject;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/stock")
@CrossOrigin //跨域在开发环境可以有，在生产环境中尽可能去除
public class StockController {
    @Autowired
    private StockService stockService;

    /**
     * 分页查询股票基本信息列表
     * @param paramMap
     * @return
     */
    @ApiOperation("分页查询股票基本信息列表接口")
    @PostMapping("/getStockBasicListByPage")
    public @ResponseBody RestObject getStockBasicListByPage(@RequestBody Map<String,Object> paramMap){
        //System.out.println(paramMap);
        //1、获取要查看第几页
        Integer pageNum = Integer.parseInt(
                paramMap.get("pageNum").toString()
        );
        //2、获取一页展示记录数
        Integer pageSize = Integer.parseInt(
                paramMap.get("pageSize").toString()
        );
        //System.out.println(pageNum+":"+pageSize);
        //3、调用service层，返回分页数据结果
        return stockService.getStockBasicListByPage(pageNum,pageSize);
    }
}
